package com.example.arithmeticleetcode.leetcode.July;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-07-27 10:42
 **/
public class Demo10 {

    public static void main(String[] args) {
        String s1 = "codeleet";
        int[] indices1 = {4, 5, 6, 7, 0, 2, 1, 3};
        System.out.println(restoreString(s1, indices1));
    }

    public static String restoreString(String s, int[] indices) {
        Map<Integer, Character> map = new HashMap<>(indices.length);
        for (int i = 0, len = indices.length; i < len; i++) {
            System.out.println(indices[i] + "===" + s.charAt(i));
            map.put(indices[i], s.charAt(i));
        }
        StringBuffer sb = new StringBuffer();
        System.out.println(map);
        for (int i = 0, len = indices.length; i < len; i++) {
            System.out.println("------" + map.get(i));
            sb.append(map.get(i));
        }
        return sb.toString();
    }
}
